The present invention generally relates to a coder unit for variable word length codes, and more particularly to a coder unit for variable word length codes in which the higher an occurrence frequency of information is the shorter the word length of the code into which the information is converted so that an average word length of codes becomes minimized. The present invention can be suitably applied to a Huffman coding on natural images.
A technique which is obtained by combining an orthogonal transformation and a variable word length coding has been proposed as a desirable coding in which natural images (static images) can be effectively coded into compressed codes. It has been decided to use this technique for an international standardized coding on a color static image (THE JOURNAL OF THE INSTITUTE OF IMAGE ELECTRONICS ENGINEERS OF JAPAN : Vol. 18, No. 6, p. 398-p. 407).
FIG. 1 is a block diagram illustrating a processing procedure in a "Baseline system" of the international standardization system.
Referring to FIG. 1, step P.sub.1 divides an input image into blocks each formed of p.times.p pixels, such as 8.times.8 pixels, and subjects each block to a discrete cosine transform (DCT) so as to obtain DCT coefficients. Step P.sub.2 performs quantization by dividing the DCT coefficients by each threshold value in a quantization matrix which is formed of p.times.p threshold values. As a resulting value obtained by the above dividing operation in step P.sub.2 includes a decimal fraction, the resulting value is converted into an integer by use of a half-adjust operation.
The DCT (discrete cosine transform) is a type of orthogonal transformation of frequency. The DCT coefficients F.sub.ij (i,j=0,1,2, . . . , p-1) obtained by the DCT represent spatial frequency components obtained by resolution of image data in each block. The larger the suffix numbers i and j are, the higher the spatial frequency of the component (A.C. component) represented by a corresponding DCT coefficient becomes. A coefficient F.sub.00 represents a value (D.C. component) proportional to an average value in the p.times.p pixels. In a coding of color images, an RGB signal is converted into a luminance signal Y and a chrominance signal C and then both signals are coded so as to decrease correlation among chrominance components. Thus, a quantization matrix for the luminance signal Y shown in FIG. 2 and a quantization matrix for the chrominance signal C matrix shown in FIG. 3 are used in step P.sub.2.
Step P.sub.3 obtains a difference between the D.C. component of the DCT coefficients which are presently quantized and the D.C. component which has been obtained by the quantization of a previous block. Then, step P.sub.4 codes a number of bits of this difference in accordance with the Huffman coding. On the other hand, with respect to the A.C. components of the quantized DCT coefficients, step P.sub.3 makes a zigzag scanning within each block according to a path shown by a line in FIG. 4 to convert the DCT coefficients F.sub.ij into an one-dimensional sequence and codes a number of consecutive zeros (invalid coefficients) in accordance with a run length coding. Then step P.sub.4 codes the number of consecutive zeros subjected to the run length coding and a number of bits of each valid coefficient which is not equal to zero in accordance with a two-dimensional Huffman coding.
As has been described above, with respect to both the D.C. component and the A.C. component, the quantized coefficient value itself is not directly coded, the number of bits required for representing the quantized coefficient value being coded in accordance with the Huffman coding. The value of the number of bits is added independently to the Huffman code as additional information (additional bits). For example, when the quantized coefficient is "3" in decimal, this quantized coefficient in binary becomes "000 . . . 011". In this case, the number of bits "2" which is required for representing this quantized coefficient is coded in accordance with the Huffman coding. Then, data "11" which is represented by lower two bits in the quantized coefficient is connected to the Huffman code as the additional information. When the quantized coefficient has a negative value, data obtained by subtracting "1" from the additional bits is added to the Huffman code. For example, when the quantized coefficient is "-2" in decimal, the quantized coefficient in binary becomes "111 . . . 110". In this case, the lower 2 bits "10" are added bits, and data "01" which is obtained by subtracting "1" from "10" is added to the Huffman code as the additional information. As a result, the additional information (the additional bits) begins with the data "1" when the quantized coefficient has a positive value and begin with the data "0" when the quantized coefficient has a negative value. Thus, it is possible to easily distinguish the polarity of the quantized coefficient.
The above standardization in accordance with the "Baseline system" is conventionally used for various types of communications such as facsimile communications and the like. Thus, the conventional coder unit which operates in accordance with the "Baseline system" outputs the Huffman code so that bits of the Huffman code continuously stream out in a line. That is, the Huffman code is output, as serial data, from the conventional coder unit. Thus, in a case where the conventional coder unit in which data is converted into the variable length word code such as the Huffman code is used for coding the static image data and the like, the transmission rate in a case where the data is output is relatively small, and the post processing is delayed.